#include <my_header.h>

/* Usage: ./7_DNS_tencent */
int main(void){                                  
    
    struct addrinfo *res;

    getaddrinfo("tencent.com", NULL, NULL, &res);
    printf("腾讯ip地址：\n");
    for(struct addrinfo *p = res; p != NULL; p = p->ai_next)
    {
        struct sockaddr *ipTag = p->ai_addr;
        if(p->ai_family == AF_INET)
        {
            struct sockaddr_in *socktTagV4 = (struct sockaddr_in *)ipTag;
            struct in_addr ipTagV4  = socktTagV4->sin_addr;

            char *strIP = inet_ntoa(ipTagV4);
            printf("ipv4, ip =%s\n", strIP);
        }
    }
    freeaddrinfo(res);
    return 0;
}


